package ws;

import java.util.ArrayList;
import java.util.Collection;

import org.orm.PersistentException;
import com.google.gson.Gson;
import Completar.CompletarAlumno;

public class AlumnoS {
        
        public static String find(int cursoId) {
                int id = 1;
                String json = null;
                int length2 = 0;
                orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
                Collection<CompletarAlumno> colectionCompletarAlumno = new ArrayList<CompletarAlumno>();
                orm.Alumno[] ormAlumnos;  
                try {
                        ormAlumnos = lDAOFactory.getAlumnoDAO().listAlumnoByQuery( "tan_cursocur_id='" + cursoId + "'", null);
                        for (int i = 0; i < ormAlumnos.length; i++) {
                    System.out.println(ormAlumnos[i].getAlu_nombre());
                        CompletarAlumno objeto = CompletarAlumno.crearAlumno(ormAlumnos[i]);
                        colectionCompletarAlumno.add(objeto);
                        }// Se crear el objeto gson para guardar los datos
                        Gson gson = new Gson();
                        json = gson.toJson(colectionCompletarAlumno);
        
                } catch (PersistentException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        } 
                return json; 
                
        }
                
}
